using System.Runtime.InteropServices;
using Be.Timvw.Framework.Win32.SafeHandles;
using System;

namespace Be.Timvw.Framework.Win32
{
    internal static class NativeMethods
    {
        private const string Advapi32File = "advapi32.dll";

        private const CharSet DefaultCharSet = CharSet.Unicode;
        private const bool DefaultSetLastError = true;
        private const string Kernel32File = "kernel32.dll";

        /// <see cref="http://msdn.microsoft.com/en-us/library/ms724211.aspx"/>
        [DllImport(Kernel32File, CharSet = DefaultCharSet, SetLastError = DefaultSetLastError)]
        internal static extern bool CloseHandle(IntPtr handle);

        /// <see cref="http://msdn.microsoft.com/en-us/library/aa378184(VS.85).aspx"/>
        [DllImport(Advapi32File, CharSet = DefaultCharSet, SetLastError = DefaultSetLastError)]
        internal static extern bool LogonUser(string userName, string domain, SafeGlobalAllocUnicodeHandle passwordHandle, LogonType logonType, LogonProvider logonProvider, out SafeTokenHandle userTokenHandle);
    }
}